package com.zhagnfei.cofig;

import org.springframework.core.io.ByteArrayResource;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Component;
import org.springframework.web.reactive.function.BodyInserters;
import org.springframework.web.reactive.function.server.ServerRequest;
import org.springframework.web.reactive.function.server.ServerResponse;
import reactor.core.publisher.Mono;

import java.nio.charset.StandardCharsets;



@Component
public class ExampleHandler {

    public Mono<ServerResponse> getUser(ServerRequest request) {
        // 获取参数信息
        String result = "函数式编程 getUser success";
        byte[] bytes = result.getBytes(StandardCharsets.UTF_8);
        return ServerResponse.status(HttpStatus.OK)
                .body(BodyInserters.fromResource(new ByteArrayResource(bytes)));
    }

}
